Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix SQL injection in jsonExtract - #153

Open
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
sentinel/fix-jsonextract-sql-injection-11874196301144504513
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix SQL injection in jsonExtract#153
Donach wants to merge 1 commit into
cfx/android-hermes-clientfrom
sentinel/fix-jsonextract-sql-injection-11874196301144504513

Conversation

@Donach

@Donach Donach commented Jul 23, 2026

Copy link
Copy Markdown

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: The jsonExtract function in packages/core/src/db/database-wrapper.ts used sql.raw to insert JSON path keys into PostgreSQL -> and ->> operators without parameterization.
🎯 Impact: Using sql.raw directly injects strings into the SQL query, bypassing parameterization and creating a potential SQL injection vulnerability if any JSON path keys are derived from user input.
πŸ”§ Fix: In Drizzle ORM, never use sql.raw() to interpolate dynamic variables. To prevent SQL injection when working with PostgreSQL JSON operators (->, ->>), we always explicitly cast dynamic parameters to text (e.g., sql\->> (${key}::text)`) to properly resolve the overloaded operator type. We used sql.jointo safely combine these parameterized template literals when chaining multi-level paths. βœ… **Verification:** Verified by checking thatjsonExtractsafely outputs parametrized values during string interpolation.pnpm build, pnpm test, and pnpm lint` passed without issue.


PR created automatically by Jules for task 11874196301144504513 started by @Donach

This change fixes a potential SQL injection vulnerability in `packages/core/src/db/database-wrapper.ts`.

The `jsonExtract` function previously used `sql.raw` to interpolate JSON path keys into PostgreSQL `->` and `->>` operators. This bypasses Drizzle's parameterization and could allow SQL injection if the path variables ever depend on user input.

The fix replaces `sql.raw` with standard string parameterization, explicitly casting the parameters to `::text` before being applied to the operators.
@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant